﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Restbucks.Shared.Representations;
using Restbucks.Shared.Domain;
using Restbucks.Shared.Mappers;

namespace Restbucks.Server.Activities
{
    public interface IReadOrderActivity { };

    class ReadOrderActivity : IReadOrderActivity
    {

        private readonly OrderRepository _repository;

        public ReadOrderActivity(OrderRepository repository)
        {
            _repository = repository;
        }

        public OrderRepresentation[] ReadOrders()
        {
            Order[] orders = _repository.GetOrders();
            
            List<OrderRepresentation> list = new List<OrderRepresentation>();
            foreach(Order o in orders) {
                list.Add(OrderRepresentationMapper.GetRepresentation(o));
            }
            return list.ToArray();
        }
    }
}
